<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="p" uri="/pagination-tags"%>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
<%@ taglib prefix="security" uri="/security-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
&nbsp;
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><s:property value="titleName"/>查询</title>


<script type="text/javascript"> 
function changeStoreType(){
	$.post("${dynamicURL}/basicdata/queryStoreJson.action", {storeType:$("#storeType").val()}, function (data) {  
        /* 清空城市 */  
        $("#storeIdName option[value!='']").remove();  
        var jsonObj = eval(data);  
        for (var i = 0; i < jsonObj.length; i++) {  
            var $option = $("<option></option>");  
            $option.attr("value", jsonObj[i].id);  
            $option.text(jsonObj[i].name);  
            $("#storeIdName").append($option);  
        }  
    });  	
}

</script>
  
</head>
<body> 
<div id="breadcrumbs">
	<div><div><ul>
		<li class="first"></li>
		<li><a href="#">入库数据</a></li>
		<li><a href="#">入库管理</a></li>
		<li class="last"><a href="#"><s:property value="titleName"/>查询</a></li>
	</ul></div></div>
</div>

<div class="section">	
	<div class="box">
		<div class="title">
			查询条件
			<span class="hide"></span>
		</div>
		<div class="content">
			<s:form action="searchAsnHeader" namespace="/report" method="post" id="searchForm">
				<s:hidden name="actionCommand" id="actionCommand" />
				<table>
					<tr>
						<td>门店类型:<s:select id="storeType" name="searchModel.storeType" list="storeTypeList" listKey="id" listValue="name" headerKey="" headerValue="所有" onchange='changeStoreType()' cssClass="leftSelect"/></td>
						<td>&nbsp;&nbsp;&nbsp;&nbsp;门&nbsp;&nbsp;店:<s:select id="storeIdName"  name="searchModel.storeId" list="storeList" listKey="id" listValue="name" headerKey="" headerValue="所有" cssClass="leftSelect"/></td>
						<td>门店代码:<s:textfield name="searchModel.storeCode" /></td>
						<td>门店名称:<s:textfield name="searchModel.storeName" /></td>						
					</tr>
					<tr>
						<td>开始时间:<select name="startYear">
										<option value="2010">2010</option>
										<option value="2011">2011</option>
										<option value="2012">2012</option>
										<option value="2013">2013</option>
										<option value="2014">2014</option>
										<option value="2015">2015</option>
										<option value="2016">2016</option>
										<option value="2017">2017</option>
										<option value="2018">2018</option>
										<option value="2019">2019</option>
										<option value="2020">2020</option>
										<option value="2021">2021</option>
										<option value="2022">2022</option>
										<option value="2023">2023</option>
										<option value="2024">2024</option>
										<option value="2025">2025</option> 
								  </select>
									月份<select name="endYear">
										<option value="1">1</option>
										<option value="2">2</option>
										<option value="3">3</option>
										<option value="4">4</option>
										<option value="5">5</option>
										<option value="6">6</option>
										<option value="7">7</option>
										<option value="8">8</option>
										<option value="9">9</option>
										<option value="10">10</option>
										<option value="11">11</option>
										<option value="12">12</option>
								  </select>
						</td>
						<td>结束时间:
							<select name="endYear">
										<option value="2010">2010</option>
										<option value="2011">2011</option>
										<option value="2012">2012</option>
										<option value="2013">2013</option>
										<option value="2014">2014</option>
										<option value="2015">2015</option>
										<option value="2016">2016</option>
										<option value="2017">2017</option>
										<option value="2018">2018</option>
										<option value="2019">2019</option>
										<option value="2020">2020</option>
										<option value="2021">2021</option>
										<option value="2022">2022</option>
										<option value="2023">2023</option>
										<option value="2024">2024</option>
										<option value="2025">2025</option> 
							</select>

						月份:
							<select name="endMonth">
										<option value="1">1</option>
										<option value="2">2</option>
										<option value="3">3</option>
										<option value="4">4</option>
										<option value="5">5</option>
										<option value="6">6</option>
										<option value="7">7</option>
										<option value="8">8</option>
										<option value="9">9</option>
										<option value="10">10</option>
										<option value="11">11</option>
										<option value="12">12</option>
								  </select>
						</td>
						<td>	
							<input type="button" value="查询" class="button orange" id="addRoleBtn" onclick="searchFormFunc()"/>
						</td>
						<td>
							<input type="button" value="导出Excel" class="button blue" id="addRoleBtn" onclick="exportResult()"/>	
						</td>
					</tr>
					<tr>
						<td colspan='4'>
						</td>
					</tr>												
				</table>
			</s:form>
		</div>
	</div>
	<div class="box">		
		<div style="margin: 5px">
			<div  id="roleInRoleListDiv" style="margin-top: 5px">
				<table id="roleInRoleList"></table> 
			    <div id="roleInRolePager"></div>   
			</div> 
		</div>
	</div>
</div>



<script type="text/javascript">
function searchFormFunc(action){
	var query = $('#searchForm').serialize(); // 序列化参数
	$("#roleInRoleList").jqGrid('setGridParam',{url: 'monthlyDeliverJson.action?'+query}).trigger("reloadGrid");
}

function exportResult(){
	var form = document.getElementById("searchForm");
	form.action="${dynamicURL}/report/exportMonthlyDeliver.action";
	form.submit();	
}

$(document).ready(function (){  
		//--------------------------------------角色包含角色-------------------------------------------------
		var roleInRoleGridList;
		//var roleId = document.getElementById('thisroleid').value;
		
		roleInRoleGridList = {   
				url: '${dynamicURL}/report/monthlyDeliverJson.action',
				colNames: ['id','区域','门店名', '门店代码', '日期','开票金额','销售金额','操作'],
			colModel: [
				        {name:'id',index:'id', frozen:true, align:"left", hidden:true},
				        {name:'regionName',index:'regionName', frozen:true, align:"left"},
						{name:'storeName',index:'storeName', frozen:true, align:"left"},
				   		{name:'storeCode',index:'storeCode', align:"left"},
				   		{name:'reportDate',index:'reportDate', align:"left", width: '200'}, 			   		
				   		{name:'invoiceAmount',index:'invoiceAmount', align:"center"},				   		  		
				   		{name:'saleAmount',index:'saleAmount', align:"center"},
				   		{name:'btn',index:'btn',align:"center"}
				   	], 
		   	shrinkToFit: false,
				height: 260,
				width: 700,
				rowNum: 20,
				rownumbers: true,
				caption: '入库单列表',
				pager: '#roleInRolePager',
				jsonReader:{
					root:"pager.records",
					total: "total",
					page: "page",
					records: "records",
					repeatitems: false,
					id:"0" },
				gridComplete: function() {
				        var grid = jQuery("#roleInRoleList");
				        var ids = grid.jqGrid('getDataIDs');	// 获取表格所有 行id
				        for (var i = 0; i < ids.length; i++) {
				            var rowId = ids[i];
				            var rowdata = grid.jqGrid('getRowData', rowId);
				            //var tempBtn = "<img title='添加库存' style='cursor:pointer' border='0'  src='${staticURL}/default/images/add.png' onclick='updateForm("+rowdata.id+")'>";  
				            //grid.jqGrid('setRowData', rowId, { btn: tempBtn}); 
				        } 
				    }
		};
		$("#roleInRoleList").jqGrid(roleInRoleGridList);
		$("#roleInRoleList").setGridWidth(jQuery("#roleInRoleListDiv").width() * 0.98);
		
		var STATUS_TYPE = {'1': '新建', '2': '已审核','3': '已过账','D':'删除','C':'取消'};
		function satus_type(cellvalue, options, rowObject) {
			return STATUS_TYPE[cellvalue];
		}
		
		//FRESH('F',"新建"),PASSED('P',"已审核"),ACCOUNT('A',"已过账"),DELETED('D',"删除"),CANCEL('C',"取消");
		
		var ANS_TYPE={10:'正常',20:'返回',30:'盘点',40:'报损'};
		function asn_type(cellvalue, options, rowObject) {
			return ANS_TYPE[cellvalue];
		}
		
});

</script>
</body>
</html>
